﻿namespace net.zxteam.ZXLexer
{
	using System;

	public struct DisposableScope : IDisposable
	{
		private readonly Action _enter, _exit;

		public DisposableScope(Action enter, Action exit)
		{
			if (enter == null) throw new ArgumentNullException();
			if (exit == null) throw new ArgumentNullException();

			_enter = enter;
			_exit = exit;

			_enter();
		}

		public void Dispose() { if (_exit != null) _exit(); }
	}
}
